#ifndef __SPI_H__
#define __SPI_H__
#include "gd32f30x.h"

#define SPI_MASTER_MODE_POLL            0
#define SPI_MASTER_MODE_DMA             1
#define SPI_MASTER_SLAVE_MODE_INT              2
#define SPI_MASTER_SLAVE_MODE_POLL      3

#ifdef ENABLE_SPI_TEST
#define SPI_MODE              SPI_MASTER_SLAVE_MODE_INT  
#else
#define SPI_MODE
#endif

#if SPI_MODE == SPI_MASTER_MODE_POLL

void spi1_config(void);

void spi1_write_read_data(uint8_t *w_data,uint8_t *r_data,int len);
void spi1_read_data(uint8_t *r_data,int len);
void spi1_write_data(uint8_t *w_data,int len);

uint8_t spi1_rw_onebyte(uint8_t w_data);
#elif SPI_MODE == SPI_MASTER_MODE_DMA

void spi1_dma_tx_data(uint8_t *p_data,uint8_t len);
void spi1_dma_init(void);
void spi1_dma_rx_data(uint8_t *p_data,uint8_t len);



#elif SPI_MODE == SPI_MASTER_SLAVE_MODE_POLL
void spi1_slave_config(void);
void spi0_master_config(void);
void spi_master_slave_fullduplex_poll(void);

#elif SPI_MODE == SPI_MASTER_SLAVE_MODE_INT

void spi1_slave_config(void);
void spi0_master_config(void);
#endif //SPI_MODE == SPI_MASTER_MODE_POLL

#endif //__SPI_H__